* Replication file for Amatller and Lindvall, "The Telegraph and Turnout: Evidence from Sweden"

* Import data

clear

use Amatller_Lindvall_data_Stata

* Define variables identifying electoral districts and periods and set panel data

encode district, gen(districtn)

generate periodn = 1 if period == 1872

replace periodn = 2 if period == 1875

replace periodn = 3 if period == 1878

xtset districtn periodn

* Define outcome variable (logged participation)

gen log_ratio_participation = log10(100*ratio_participation)

* Define explanatory variable (logged average distance to nearest telegraph)

gen dist_km = dist_to_nearest*10

gen dist_log = log10(dist_km + 1)

* Define control variables

generate evoterslog = log(elegible_voters*1000)

* Define newspaper variable for split-sample analysis 

generate newsindistrict = 0 if newspapers != .

replace newsindistrict = 1 if newspapers > 0 & newspapers != .

* Global macros for variables included in the analysis

global controls "evoterslog direct_indirect"

global periods "i.periodn"

* Analysis

* Drop the Stockholm electoral district

drop if district == "Stockholm"

* Run regressions for Table 2

preserve

* Full sample (column 2)

xtreg log_ratio_participation c.dist_log $controls $periods, fe

* Define a variable with quartiles of distance variable and run analysis for restricted sample (column 1)

xtile quart = dist_log if periodn == 1, nq(4)

bysort districtn: egen remove = max(quart)

xtreg log_ratio_participation c.dist_log $controls $periods if remove != 1, fe

restore

* Run regressions for Table 3

preserve

* Define a variable with quartiles of distance variable and run analysis for restricted sample

xtile quart = dist_log if periodn == 1, nq(4)

bysort districtn: egen remove = max(quart)

xtreg log_ratio_participation c.dist_log $controls $periods if newsindistrict == 0 & remove != 1, fe

xtreg log_ratio_participation c.dist_log $controls $periods if newsindistrict == 1 & remove != 1, fe

restore

* Run regressions for Supplementary Materials

* Define a variable with quartiles of distance variable and run analysis for restricted sample

xtile quart = dist_log if periodn == 1, nq(4)

bysort districtn: egen remove = max(quart)

foreach d in 10 30 50 70 90 110 {

generate d_`d' = 0 if dist_km != .

replace d_`d' = 1 if dist_km <= `d'

xtreg log_ratio_participation d_`d' $controls $periods if remove != 1, fe

}